package com.ohos.carbon.slice;

import com.ohos.carbon.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.Image;
import ohos.agp.components.Text;
import ohos.agp.components.element.ElementScatter;

import static com.ohos.carbon.ResourceTable.*;

public class ButtonCodeSlice extends AbilitySlice {
    private Text codeText, textTitle;
    private Image checkbox, back_button, debug;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(Layout_ability_button_code);
        initView();
    }

    public void initView() {
        back_button = (Image) findComponentById(Id_back_button);
        back_button.setImageElement(ElementScatter.getInstance(getContext()).parse(ResourceTable.Graphic_carbon_uparrow));
        back_button.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                onBackPressed();
            }
        });

        debug = (Image) findComponentById(Id_image1);
        debug.setVisibility(Component.HIDE);
        checkbox = (Image) findComponentById(Id_image2);
        checkbox.setVisibility(Component.HIDE);
        textTitle = (Text) findComponentById(Id_title_text);
        textTitle.setText("Button Code");

        codeText = (Text) findComponentById(ResourceTable.Id_code_text);
        codeText.setText(code);
    }

    String code = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
            "<DirectionalLayout\n" +
            "    xmlns:ohos=\"http://schemas.huawei.com/res/ohos\"\n" +
            "    ohos:height=\"match_parent\"\n" +
            "    ohos:width=\"match_parent\"\n" +
            "    ohos:orientation=\"vertical\">\n" +
            "\n" +
            "    <DirectionalLayout\n" +
            "        ohos:height=\"match_content\"\n" +
            "        ohos:width=\"match_parent\"\n" +
            "        ohos:orientation=\"horizontal\">\n" +
            "\n" +
            "        <include\n" +
            "            ohos:height=\"60vp\"\n" +
            "            ohos:width=\"match_parent\"\n" +
            "            layout=\"$layout:back_titlebar\">\n" +
            "        </include>\n" +
            "    </DirectionalLayout>\n" +
            "\n" +
            "    <ScrollView\n" +
            "        ohos:height=\"match_parent\"\n" +
            "        ohos:width=\"match_parent\">\n" +
            "\n" +
            "        <DirectionalLayout\n" +
            "            ohos:height=\"match_content\"\n" +
            "            ohos:width=\"match_parent\"\n" +
            "            ohos:orientation=\"vertical\">\n" +
            "\n" +
            "            <DirectionalLayout\n" +
            "                ohos:height=\"match_content\"\n" +
            "                ohos:width=\"match_parent\">\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\">\n" +
            "\n" +
            "                    <Text\n" +
            "                        ohos:text_color=\"#999999\"\n" +
            "                        ohos:text_size=\"12fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"Plain buttons with different styles\"\n" +
            "                        ohos:top_margin=\"8vp\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Text>\n" +
            "\n" +
            "                    <Image\n" +
            "                        ohos:id=\"$+id:button_images_one\"\n" +
            "                        ohos:background_element=\"$graphic:ic_code_black_24dp\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:image_src=\"$media:icon\"\n" +
            "                        ohos:right_margin=\"15vp\"\n" +
            "                        ohos:top_margin=\"8vp\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Image>\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"25vp\">\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:focusable=\"focus_enable\"\n" +
            "                        ohos:foreground_element=\"$graphic:ripple_foreground\"\n" +
            "                        ohos:clickable=\"true\"\n" +
            "                        ohos:background_element=\"$graphic:btn_round\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"CONTAINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:background_element=\"$graphic:btn_buttons\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:right_margin=\"17vp\"\n" +
            "                        ohos:text=\"OUTLINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"28vp\">\n" +
            "                    <Button\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:text=\"FLAT BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "                </DependentLayout>\n" +
            "            </DirectionalLayout>\n" +
            "            <DirectionalLayout\n" +
            "                ohos:height=\"match_content\"\n" +
            "                ohos:width=\"match_parent\">\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"25vp\">\n" +
            "\n" +
            "                    <Text\n" +
            "                        ohos:visibility=\"invisible\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:left_margin=\"10vp\"\n" +
            "                        ohos:text=\"Plain buttons with different styles\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Text>\n" +
            "\n" +
            "                    <Image\n" +
            "                        ohos:id=\"$+id:button_images_two\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:image_src=\"$media:icon\"\n" +
            "                        ohos:right_margin=\"15vp\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Image>\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"30vp\">\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:background_element=\"$graphic:btn_round\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"CONTAINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:background_element=\"$graphic:btn_buttons\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:right_margin=\"17vp\"\n" +
            "                        ohos:text=\"OUTLINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"28vp\">\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"50vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:text=\"FLAT BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "                </DependentLayout>\n" +
            "            </DirectionalLayout>\n" +
            "            <DirectionalLayout\n" +
            "                ohos:height=\"match_content\"\n" +
            "                ohos:width=\"match_parent\">\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"20vp\">\n" +
            "\n" +
            "                    <Text\n" +
            "                        ohos:text_color=\"#999999\"\n" +
            "                        ohos:text_size=\"12fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"Colored styles\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Text>\n" +
            "\n" +
            "                    <Image\n" +
            "                        ohos:id=\"$+id:button_images_three\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:image_src=\"$media:icon\"\n" +
            "                        ohos:right_margin=\"15vp\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Image>\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"30vp\">\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:background_element=\"$graphic:btn_shape\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"CONTAINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:background_element=\"$graphic:btn_buttons\"\n" +
            "                        ohos:text_color=\"#008080\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:right_margin=\"17vp\"\n" +
            "                        ohos:text=\"OUTLINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"28vp\">\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:text_color=\"#008080\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:text=\"FLAT BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "                </DependentLayout>\n" +
            "            </DirectionalLayout>\n" +
            "            <DirectionalLayout\n" +
            "                ohos:height=\"match_content\"\n" +
            "                ohos:width=\"match_parent\">\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"20vp\">\n" +
            "\n" +
            "                    <Text\n" +
            "                        ohos:visibility=\"invisible\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"Plain buttons with different styles\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Text>\n" +
            "\n" +
            "                    <Image\n" +
            "                        ohos:id=\"$+id:button_images_four\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:image_src=\"$media:icon\"\n" +
            "                        ohos:right_margin=\"15vp\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Image>\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"25vp\">\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:background_element=\"$graphic:btn_shape\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"CONTAINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:background_element=\"$graphic:btn_buttons\"\n" +
            "                        ohos:text_color=\"#008080\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:right_margin=\"17vp\"\n" +
            "                        ohos:text=\"OUTLINED BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                </DependentLayout>\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"28vp\">\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:text_color=\"#008080\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"38vp\"\n" +
            "                        ohos:width=\"150vp\"\n" +
            "                        ohos:text=\"FLAT BUTTON\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Button>\n" +
            "                </DependentLayout>\n" +
            "            </DirectionalLayout>\n" +
            "            <DirectionalLayout\n" +
            "                ohos:height=\"match_content\"\n" +
            "                ohos:width=\"match_parent\">\n" +
            "\n" +
            "                <DependentLayout\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\"\n" +
            "                    ohos:top_margin=\"20vp\">\n" +
            "\n" +
            "                    <Text\n" +
            "                        ohos:text_color=\"#999999\"\n" +
            "                        ohos:text_size=\"12fp\"\n" +
            "                        ohos:id=\"$+id:button_text_one\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:text=\"Plain buttons with different styles\"\n" +
            "                        ohos:top_margin=\"8vp\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Text>\n" +
            "\n" +
            "                    <Image\n" +
            "                        ohos:id=\"$+id:button_images_five\"\n" +
            "                        ohos:height=\"match_content\"\n" +
            "                        ohos:width=\"match_content\"\n" +
            "                        ohos:align_parent_right=\"true\"\n" +
            "                        ohos:image_src=\"$media:icon\"\n" +
            "                        ohos:right_margin=\"15vp\"\n" +
            "                        ohos:vertical_center=\"true\">\n" +
            "                    </Image>\n" +
            "                </DependentLayout>\n" +
            "                <DirectionalLayout\n" +
            "                    ohos:orientation=\"vertical\"\n" +
            "                    ohos:height=\"match_content\"\n" +
            "                    ohos:width=\"match_parent\">\n" +
            "                    <Button\n" +
            "                        ohos:id=\"$+id:btn_half\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:right_padding=\"8vp\"\n" +
            "                        ohos:left_padding=\"8vp\"\n" +
            "                        ohos:top_margin=\"30vp\"\n" +
            "                        ohos:background_element=\"#000000\"\n" +
            "                        ohos:text_color=\"#FFFFFF\"\n" +
            "                        ohos:text=\"CUSTOM SHAPE\"\n" +
            "                        ohos:height=\"33vp\"\n" +
            "                        ohos:width=\"match_content\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:id=\"$+id:btn_shadow\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:right_padding=\"8vp\"\n" +
            "                        ohos:left_padding=\"8vp\"\n" +
            "                        ohos:top_margin=\"30vp\"\n" +
            "                        ohos:text_color=\"#0033CC\"\n" +
            "                        ohos:background_element=\"$graphic:btn_shadow\"\n" +
            "                        ohos:text=\"CUSTOM SHAPE\"\n" +
            "                        ohos:height=\"33vp\"\n" +
            "                        ohos:width=\"match_content\">\n" +
            "                    </Button>\n" +
            "\n" +
            "                    <Button\n" +
            "                        ohos:id=\"$+id:btn_shadow\"\n" +
            "                        ohos:text_size=\"14fp\"\n" +
            "                        ohos:left_margin=\"15vp\"\n" +
            "                        ohos:right_padding=\"8vp\"\n" +
            "                        ohos:left_padding=\"8vp\"\n" +
            "                        ohos:top_margin=\"30vp\"\n" +
            "                        ohos:text_color=\"#FF9900\"\n" +
            "                        ohos:background_element=\"$graphic:btn_oval\"\n" +
            "                        ohos:text=\"ROUNDED WITH RIPPLE\"\n" +
            "                        ohos:height=\"33vp\"\n" +
            "                        ohos:width=\"match_content\">\n" +
            "                    </Button>\n" +
            "<!--                    <DependentLayout-->\n" +
            "<!--                        ohos:top_margin=\"50vp\"-->\n" +
            "<!--                        ohos:height=\"match_content\"-->\n" +
            "<!--                        ohos:width=\"match_content\">-->\n" +
            "<!--                        <Image-->\n" +
            "<!--                            ohos:id=\"$+id:btn_fold\"-->\n" +
            "<!--                            ohos:image_src=\"$media:aaa\"-->\n" +
            "<!--                            ohos:height=\"60vp\"-->\n" +
            "<!--                            ohos:width=\"220vp\">-->\n" +
            "<!--                        </Image>-->\n" +
            "<!--                        <Text-->\n" +
            "<!--                            ohos:center_in_parent=\"true\"-->\n" +
            "<!--                            ohos:text=\"CUSTOM\"-->\n" +
            "<!--                            ohos:text_color=\"#FFFFFF\"-->\n" +
            "<!--                            ohos:text_size=\"24fp\"-->\n" +
            "<!--                            ohos:height=\"match_content\"-->\n" +
            "<!--                            ohos:width=\"match_content\">-->\n" +
            "<!--                        </Text>-->\n" +
            "\n" +
            "<!--                    </DependentLayout>-->\n" +
            "                        <Button\n" +
            "                            ohos:bottom_margin=\"30vp\"\n" +
            "                            ohos:text_size=\"25fp\"\n" +
            "                            ohos:text_color=\"#FFFFFF\"\n" +
            "                            ohos:text=\"CUSTOM\"\n" +
            "                            ohos:id=\"$+id:btn_fold\"\n" +
            "                            ohos:left_margin=\"15vp\"\n" +
            "                            ohos:right_padding=\"8vp\"\n" +
            "                            ohos:left_padding=\"8vp\"\n" +
            "                            ohos:top_margin=\"30vp\"\n" +
            "                            ohos:background_element=\"$media:aaa\"\n" +
            "                            ohos:height=\"60vp\"\n" +
            "                            ohos:width=\"220vp\">\n" +
            "                        </Button>\n" +
            "                </DirectionalLayout>\n" +
            "            </DirectionalLayout>\n" +
            "\n" +
            "        </DirectionalLayout>\n" +
            "\n" +
            "    </ScrollView>\n" +
            "\n" +
            "</DirectionalLayout>";

}
